/*
 * @Description: 数据校验
 * @Author: bxsdhx
 * @Date: 2021-08-02 13:31:55
 * @LastEditTime: 2024-07-12 17:32:28
 * Copyright (C) 2021 bxsdhx. All rights reserved.
 */
import hxzxUtils from "hxzx-utils";
/**
 * 各种数据类型判断
 *
 * 详细API: https://jjp.world/hxzx-utils/#/api/1.0.4/type
 */
export const typeOf = hxzxUtils.type;

/**
 * @description: 验证手机号
 * @param {string | number} value 手机号
 * @return {boolean} 是否符合规则
 */
export const phone = function (value: string | number): boolean {
  return /^1[35789]\d{9}$/.test(String(value));
};

/**
 * @description: 手机号覆盖中间四位
 * @param {string} value 手机号
 * @return {string} 覆盖后的手机号 18267896789 => 182****6789
 */
export const phones = function (value: string): string {
  return value.replace(/(\w{3})(\d+)(\d{4})/g, "$1*****$3");
};